package com.dingwen.treasure.business.controller;

import com.dingwen.treasure.base.controller.BaseViewController;
import com.dingwen.treasure.base.pojo.vo.Result;
import com.dingwen.treasure.business.model.vo.DictionaryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 　ResponseBodyAdviceController: 统一返回测试
 * 　@author dingwen
 * 　@since  2022/8/8
 */
@Api(tags = "ResponseBodyAdvice测试")
@RestController
@Slf4j
@RequestMapping("ResponseBodyAdvice")
@RequiredArgsConstructor
@Validated
public class ResponseBodyAdviceController implements BaseViewController {

    @GetMapping("void")
    @ApiOperation(value = "无返回值测试")
    public void testVoid() {
        log.info("ResponseBodyAdviceController testVoid()");
    }

    @GetMapping("boolean")
    @ApiOperation(value = "Boolean返回值测试")
    public Boolean testBoolean() {
        return Boolean.TRUE;
    }

    @GetMapping("string")
    @ApiOperation(value = "String返回值测试")
    public String testString() {
        return "success";
    }

    @GetMapping("result")
    @ApiOperation(value = "Result返回值测试")
    public Result<DictionaryVo> testResult() {
        return success();
    }

    @GetMapping("validator")
    @ApiOperation(value = "参数校验测试")
    public void testParamsValidator(@NotBlank(message = "test不能为空") @RequestParam String test,
                                    @RequestParam @NotNull(message = "num不能为空") Integer num) {
        log.info("test：{}", test);
        log.info("num：{}", num);
    }

}
